<?php
    /**
     * difF PHP Framework :: Html_Form.php
     *
     * @version: 0.5
     * @date   : 16/08/2012
     * @author Melisides Constantinos (dsphinx@gmail.com)
     * @require    : html.php
     * @Description:    html 5 features
     *                        HTML 5 session
     *  TODO:
     *
     * Licensed under MIT licence:
     *   http://www.opensource.org/licenses/mit-license.php
     **/


    class Html_Form
    {

        static $_key_name = '_call_form';


        /**
         * @return string
         *
         *  Generate md5 hash for protecting FORM POSTS
         *
         */
        static function _set_call($keytoset = NULL)
        {
            $keytoset            = isset($keytoset) ? $keytoset : self::$_key_name;
            $_FORM_KEY           = md5(__DIR__ . __METHOD__ . time());
            $_SESSION[$keytoset] = $_FORM_KEY;

            return '<input type="hidden" name="' . $keytoset . '" value="' . $_FORM_KEY . '">';
        }


        /**
         * @param      $inputkey
         * @param null $keytoset
         *
         *
         *
         * @return bool
         *
         *
         */
        static function _is_normal_call($inputkey, $keytoset = NULL)
        {
            $_return  = FALSE;
            $keytoset = isset($keytoset) ? $keytoset : self::$_key_name;
            if ($inputkey === $_SESSION[$keytoset]) {
                $_return = TRUE;
            }

            return $_return;
        }


    }

